home *** CD-ROM | disk | FTP | other *** search
/ L' Effet Pommier 3 / L'Effet Pommier - Volume 03.iso / Graphismes / Bitmap / NIH Image 1.59 / Macros / Video < prev   
Text File  |  1995-10-03  |  7KB  |  311 lines

  1. var
  2.    n:integer;  {Global variable used by integration macros}
  3.  
  4.  
  5. macro 'Print Video [P]';
  6. begin
  7.   CallExport('TV-3 Module');
  8. end;
  9.  
  10.  
  11. procedure ExtractEvenField(NewWindow:boolean);
  12. {
  13. Replaces odd scan lines with average of neighboring even lines. Can be used to improve the quality of images that have even and odd fields that are out of sync as the result of subject movement during capture.
  14. }
  15. var
  16.   i,width,height,row1,row2:integer;
  17. begin
  18.   SaveState;
  19.   if NewWindow then Duplicate('Even Field');
  20.   GetPicSize(width,height);
  21.   row1:=0; row2:=0;
  22.   for i:=1 to height/2 do begin
  23.     GetRow(0,row1,width);
  24.     PutRow(0,row2,width);
  25.     row1:=row1+2;
  26.     row2:=row2+1;
  27.   end;
  28.   MakeRoi(0,0,width,height/2);
  29.   Copy;
  30.   MakeRoi(0,height/4-1,width,height/2);
  31.   Paste;
  32.   RestoreRoi;
  33.   SetScaling('Bilinear; Same Window');
  34.   ScaleAndRotate(1,2,0);
  35.   RestoreState;
  36. end;
  37.  
  38. macro 'Extract Even Field->New Window';
  39. begin
  40.   ExtractEvenField(true);
  41. end;
  42.  
  43. macro 'Extract Even Field->Same Window';
  44. begin
  45.   ExtractEvenField(false);
  46. end;
  47.  
  48. macro 'Camera and Light Source Test╔';
  49.   {Use to test cameras and light sources for temporal stability.}
  50. var
  51.   delay,nFrames:integer;
  52.   i:real;
  53. begin
  54.    nFrames:=trunc(GetNumber('Number of Frames:',10));
  55.    delay:=trunc(GetNumber('Delay in seconds:',10));
  56.    for I:=1 to nFrames do begin
  57.      Capture;
  58.      Measure;
  59.      SetCursor('Watch');
  60.      wait(delay);
  61.   end;
  62. end;
  63.  
  64.  
  65. macro 'Average Frames [F]';
  66. begin
  67.   AverageFrames;
  68. end;
  69.  
  70.  
  71. macro 'Average Frames on Trigger';
  72. begin
  73.   WaitForTrigger;
  74.   AverageFrames;
  75. end;
  76.  
  77.  
  78. macro 'Dynamic 1-D Plot';
  79. {
  80. Displays a dynamic 1-d plot of a line in the image while the image
  81. is being captured. You most first create a line selection in
  82. Camera window. The macro works best if you first to a Plot Profile
  83. and move the Plot window so it doesn't cover the Camera window. You
  84. may have to resize the Camera window. Hold down the mouse button
  85. to terminate.
  86. }
  87. var
  88.   x1,y1,x2,y2,LineWidth:integer;
  89. begin
  90.   GetLine(x1,y1,x2,y2,LineWidth);
  91.   if x1=-1 then begin
  92.     PutMessage('Create a straight line selection in the Camera window');
  93.     exit;
  94.   end;
  95.   SetPlotScale(0,255);
  96.   repeat
  97.     Capture;
  98.     if button then exit;
  99.     MakeLineRoi(x1,y1,x2,y2);
  100.     PlotProfile;
  101.   until button;
  102. end;
  103.  
  104.  
  105. macro 'Integrate Inverted╔';
  106. {
  107. Inverts captured video to allow more than 128 frames to be
  108. integrated without overflow. For example, the sum of 256 pixels
  109. with an average value of 200(very dark) is 51,200, which is
  110. greater than the 32,767 maximum, but the sum of 256 pixels
  111. with and average value of 55(200 inverted) is 14,080.
  112. }
  113. var
  114.   nFrames:integer;
  115. begin
  116.   nFrames:=GetNumber('Number of Frames:', 200);
  117.   SetVideo('Invert');
  118.   AverageFrames('Integrate', nFrames);
  119.   SetVideo(''); {Don't invert}
  120.   Invert;
  121. end;
  122.  
  123.  
  124. macro 'Acquire AV Video [V]';
  125. begin
  126.    Acquire('Plug-in Digitizer');
  127. end;
  128.  
  129.  
  130. macro 'Acquire AV with Calibration';
  131. {Plug-in Digitiser always calibrates captured images to
  132. 72 dots per inch. To get around this problem, this macro
  133. saves the current spatial scale, calls Plug-in Digitizer 1.1,
  134. and then applies the saved scale to the captured image. The
  135. name used in the Acquire command will have to be changed
  136. if you use a different version of Plug-in Digitizer.
  137. }
  138. var
  139.    scale, AspectRatio:real;
  140.    unit:string;
  141. begin
  142.    GetScale(scale, unit, AspectRatio);
  143.    Acquire('Plug-in Digitizer 1.1');
  144.    SetScale(scale, unit, AspectRatio);
  145. end;
  146.  
  147.  
  148. macro 'Correct Aspect Ratio';
  149. var
  150.    AspectRatio: real;
  151. begin
  152.   AspectRatio := GetNumber('Aspect Ratio:' , 0.95);
  153.   SelectAll;
  154.   SetScaling('Bilinear, Same Window');
  155.   ScaleAndRotate(AspectRatio, 1, 0);
  156. end;
  157.  
  158.  
  159. macro 'Capture with "Live" Histogram';
  160. begin
  161.   StartCapturing;
  162.   ShowHistogram;
  163. end;
  164.  
  165.  
  166. macro '(-' begin end; {Menu divider}
  167. {
  168. These two macros continuously integrate and display frames either off-chip, using the Scion AG-5, or on-clip, using the Scion LG-3 and a Coho 4910 series camera. Press and hold the mouse button near the top of the Camera window to decrease the number of frames integrated. Press near the bottom to increase the number of frames integrated. Press above or to the left of the Camera window to stop integrating.
  169. }
  170.  
  171. procedure Integrate (mode:string);
  172. var
  173.    x,y,delta:integer;
  174. begin
  175.    if n=0 then n:=6;
  176.    repeat
  177.       if button then begin
  178.          GetMouse(x,y);
  179.          if (x<0) or (y<0) then exit;
  180.          delta:=round(0.333*n);
  181.          if delta<1 then delta:=1;
  182.          if y<220 then begin
  183.             n:=n-delta;
  184.             if n<1 then n:=1;
  185.          end else begin
  186.              n:=n+delta;
  187.              if n>127 then n:=127;
  188.          end;
  189.       end;
  190.       AverageFrames(mode, n);
  191.    until false;
  192. end;
  193.  
  194. macro 'Integrate Using AG-5 [5]';
  195. begin
  196.   Integrate('integrate video rate');
  197. end;
  198.  
  199. macro 'Integrate On-chip Using Cohu [C]';
  200. begin
  201.   Integrate('integrate on-chip');
  202. end;
  203.  
  204.  
  205. macro '(-' begin end; {Menu divider}
  206.  
  207. macro 'Paste Live [L]';
  208. {
  209. Pastes ╥live╙ from Camera window into a rectangular
  210. selection in another window. Use Paste Control to
  211. switch to various semi-transparent transfer modes.
  212. }
  213. begin
  214.   PasteLive;
  215. end;
  216.  
  217. macro 'Paste Averaged [A]';
  218. {
  219. Captures an averaged or integrated selection into a window
  220. other than the Camera window. Use in conjunction with "PasteLive". Useful for making montages of different focal
  221. planes of fluorescent specimens.
  222. }
  223. var
  224.   x,y,width,height,pid:integer;
  225. begin
  226.   RequiresVersion(1.53);
  227.   if WindowTitle='Camera' then begin
  228.     PutMessage('The active window cannot be "Camera".');
  229.     exit;
  230.   end;
  231.   GetRoi(x,y,width,height);
  232.    if width=0 then begin
  233.     PutMessage('Rectangular selection required.');
  234.     exit;
  235.   end;
  236.   pid:=PidNumber;
  237.   SelectWindow('Camera');
  238.   MakeRoi(x,y,width,height);
  239.   AverageFrames;
  240.   Copy;
  241.   SelectPic(pid);
  242.   MakeRoi(x,y,width,height);
  243.   Paste;
  244. end;
  245.  
  246. macro 'Paste Live OR [O]';
  247. begin
  248.   PasteLive;
  249.   SetOption; DoOr;
  250. end;
  251.  
  252. macro 'Paste Live XOR [X]';
  253. begin
  254.   PasteLive;
  255.   SetOption; DoXor;
  256. end;
  257.  
  258. macro 'Add Duplicate Slice [D]';
  259. {Use with "Paste Live OR" or "Paste Live XOR"}
  260. {to register series of sections into a stack.}
  261. begin
  262.   SetOption; DoCopy;
  263.   KillRoi;
  264.   SelectAll;
  265.   Copy;
  266.   AddSlice;
  267.   Paste;
  268. end;
  269.  
  270. macro '(-' begin end; {Menu divider}
  271.  
  272. {Note: keyboard shortcuts do not work when the Video}
  273. {Control dialog box is the active window.}
  274.  
  275. macro 'SetChannel 1 [1]'; begin SetChannel(1) end;
  276. macro 'SetChannel 2 [2]'; begin SetChannel(2) end;
  277. macro 'SetChannel 3 [3]'; begin SetChannel(3) end;
  278. macro 'SetChannel 4 [4]'; begin SetChannel(4) end;
  279.  
  280. macro '(-' begin end; {Menu divider}
  281.  
  282. macro 'Generate Pulse Train'
  283. {Outputs a 30Hz pulse train on pin 1(Data Output bit 3)}
  284. {of the Scion LG-3's utility connector.}
  285. var
  286.   NextTicks,inc:integer;
  287. begin
  288.   inc:=1; {1/60 sec.}
  289.   SetCursor('watch');
  290.   NextTicks:=TickCount+inc;
  291.   repeat
  292.     scion[4]:=BitOr(scion[4],8);
  293.     repeat until TickCount>=NextTicks;
  294.     NextTicks:=NextTicks+inc;
  295.     scion[4]:=BitAnd(scion[4],7);
  296.     repeat until TickCount>=NextTicks;
  297.     NextTicks:=NextTicks+inc;
  298.   until button;
  299. end;
  300.  
  301.  
  302. macro 'Set LG-3 DAC A'; begin scion[1]:=GetNumber('DAC A(0-255):',scion[1]); end;
  303. macro 'Set LG-3 DAC B'; begin scion[2]:=GetNumber('DAC B(0-255):',scion[2]); end;
  304. macro 'Set LG-3 Data Out'; begin scion[4]:=GetNumber('Data Out(0-15):',scion[4]); end;
  305. macro 'Read LG-3 Data In'; begin PutMessage('Data In=',BitAnd(scion[3],15):1); end;
  306.  
  307.  
  308.  
  309.  
  310.  
  311.